<template>
  <div id="liveevent">
    <!--    轮播图-->
    <div class="swiperbox">
      <el-carousel :name="swiper" direction="vertical" :autoplay="true">
        <el-carousel-item v-for="(item, i) in slideList" :key="i">
          <img :src="item.url" alt="swiper" class="swiper">
        </el-carousel-item>
      </el-carousel>
    </div>
    <!--    赛事介绍-->
    <div class="toubox">
      <div class="tou">
        <div class="hotstit">
          <div class="tit-eng">TOURNAMENT INTRODUCTION</div>
          <div class="tit-p">赛事介绍</div>
        </div>
        <div class="toucent">
          <div class="touitem" ref="animateBoxs" v-for="(item, i) in toulist" :key="i">
            <div class="touleft">
              <img :src="item.url" alt="tou">
            </div>
            <div class="touright">
            </div>
            <div class="toumask">
              <div class="toutit">{{ item.tit }}</div>
              <div class="toutype">赛事类型：</div>
              <div>
                <el-radio-group v-model="item.group1value" size="small">
                  <el-radio-button v-for="(itemson, index) in item.radiogroup1" :key="index" :label="itemson" />
                </el-radio-group>
              </div>
              <div class="toutype">赛事组别：</div>
              <div>
                <el-radio-group v-model="item.group2value" size="small">
                  <el-radio-button v-for="(itemson, index) in item.radiogroup2" :key="index" :label="itemson" />
                </el-radio-group>
              </div>
              <div class="toutype">报名时间：</div>
              <div class="timeson">{{ item.time }}</div>
              <div class="toubuts">
                <button class="toubut1" v-show="i === 0">
                  <nuxt-link to="/404">立即报名</nuxt-link>
                </button>
                <button class="toubut2" v-show="i === 0"> <nuxt-link to="/404">咨询报名</nuxt-link></button>
                <button class="toubut3" v-show="i === 1"> <nuxt-link to="/404">已报名</nuxt-link></button>
                <button class="toubut4" disabled v-show="i === 2">报名结束</button>
              </div>
            </div>
          </div>
        </div>
        <div class="lookmore" @click="lookmore">
          <img src="http://competition.duoyu021.top/index/mone.png" alt="more">
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>

useHead({
  title: '实时赛事'
})

const router = useRouter()
const swiper = ref('swiper')

const slideList = [
  { url: 'http://competition.duoyu021.top/index/liveng.png' },
  { url: 'http://competition.duoyu021.top/index/liveng.png' },
  { url: 'http://competition.duoyu021.top/index/liveng.png' },
]

const toulist = ref([
  {
    url: 'http://competition.duoyu021.top/index/tou1.png',
    tit: '赛事名称',
    radiogroup1: ['独舞', '双人舞', '民族舞'],
    group1value: '独舞',
    radiogroup2: ['芭蕾舞A组', '原创剧目B组', '芭蕾舞B组', '中国舞A组', '原创剧目A1组'],
    group2value: '芭蕾舞A组',
    time: '2023年6月1日-2023年10月1日',
    isapply: true,
    path1: '/404',
    path2: '/404',
    isbut: 1
  }, {
    url: 'http://competition.duoyu021.top/index/tou2.png',
    tit: '赛事名称',
    radiogroup1: ['独舞', '双人舞', '民族舞'],
    group1value: '',
    radiogroup2: ['芭蕾舞A组', '原创剧目B组', '芭蕾舞B组', '中国舞A组', '原创剧目A1组'],
    group2value: '',
    time: '2023年6月1日-2023年10月1日',
    isapply: true,
    path1: '/404',
    path2: '/404',
    isbut: 2
  }, {
    url: 'http://competition.duoyu021.top/index/tou3.png',
    tit: '赛事名称',
    radiogroup1: ['独舞', '双人舞', '民族舞'],
    group1value: '',
    radiogroup2: ['芭蕾舞A组', '原创剧目B组', '芭蕾舞B组', '中国舞A组', '原创剧目A1组'],
    group2value: '',
    time: '2023年6月1日-2023年10月1日',
    isapply: true,
    path1: '/404',
    path2: '/404',
    isbut: 3
  },
])

const lookmore = () => {
  router.push('/404')
}

const animateBoxs = ref([])
let observer = null

onMounted(() => {
  observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        entry.target.classList.add('animate__animated', 'animate__slideInRight')
      } else {
        entry.target.classList.remove('animate__animated', 'animate__slideInRight')
      }
    })
  })

  animateBoxs.value.forEach(box => observer.observe(box))
})

onUnmounted(()=>{
  if(observer){
    observer.disconnect()
  }
})


//获取实时赛事
const { data: datamatch } = await useAsyncData(() => {
  return getMatchList({limit:99999});
}, {
  default: () => ({})
})
// console.log(datamatch.value.data.data);
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

//轮播图
:deep(.el-carousel__indicators--right) {
  left: 20px;
  top: 80%;
}

:deep(..el-carousel__indicators--vertical) {
  left: 20px;
  top: 10%;
  transform: translateY(-80%);
}

:deep(.el-carousel__button) {
  width: 14px;
  height: 50px;
}

.swiperbox {
  position: relative;
}

:deep(.el-carousel__container) {
  height: 600px;
}


.swiper {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

//轮播图
//赛事介绍

.toubox {
  width: 100%;
  margin-top: 40px;
}

.tou {
  width: 66%;
  margin: auto;
}

.hotstit {
  display: block;
  position: relative;
  margin: auto;
  margin-top: 30px;
  margin-bottom: 30px;
  text-align: center;
}


.tit-eng {
  font-size: 2rem;
  color: #e4e4e4;
  font-weight: bold;
  transition: text-shadow 0.3s ease-in-out;
}

.tit-p {
  color: #0b6cfe;
  font-weight: bold;
  font-size: 2rem;
  position: absolute;
  top: 90%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: text-shadow 0.3s ease-in-out;
}

.tit-eng:hover {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5)
}

.tit-p:hover {
  text-shadow: 2px 2px 4px rgba(11, 108, 254, 0.5);
}

.toucent {
  width: 100%;
}

.touitem {
  width: 100%;
  height: 500px;
  max-width: 100%;
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 40px;
}

.touitem:nth-child(2) {
  flex-direction: row-reverse;

  & .touleft img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
  }

  & .touright {
    background-color: #52cf91;
    border-radius: 0;
    border-bottom-left-radius: 8px;
    border-top-left-radius: 8px;
  }

  & .toumask {
    position: absolute;
    width: 60%;
    height: 78%;
    background-color: white;
    top: 50%;
    right: 65%;
    transform: translate(-100%, -50%);
    padding: 20px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 4px;
  }
}

.touitem:nth-child(3) {
  & .touright {
    background-color: #ffb2b4;
  }
}

.touleft {
  width: 50%;

  & img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-bottom-left-radius: 8px;
    border-top-left-radius: 8px;
  }
}

.touright {
  width: 50%;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  background-color: #98bef7;
}


.toumask {
  position: absolute;
  width: 60%;
  height: 78%;
  background-color: white;
  top: 50%;
  left: 65%;
  transform: translate(-50%, -50%);
  padding: 20px 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}


.toutit {
  font-size: 24px;
  margin-bottom: 20px;
}

.toutype {
  margin-top: 10px;
}

.timeson {
  margin-top: 4px;
}

.toubuts {
  display: flex;
  margin-top: 10px;
  font-size: 12px;
}

.toubut1 {
  border: solid 1px #0b6cfe;
  color: #0b6cfe;
  background-color: white;
  padding: 5px 8px;
  box-sizing: border-box;
  border-radius: 6px;
}

.toubut2 {
  margin-left: 10px;
  background-color: #0b6cfe;
  color: white;
  padding: 5px 8px;
  box-sizing: border-box;
  border-radius: 6px;
  transition: background-position 0.3s ease-in-out;
  /* 添加过渡效果 */
  background-size: 200% 100%;
  background-image: linear-gradient(to right, #3498db 50%, #f39c12 50%);
}

.toubut2:hover {
  background-position: -100% 0;
  /* 移动背景图位置 */
}

.toubut3 {
  border: solid 1px #ff6569;
  background-color: #ff6569;
  color: white;
  padding: 5px 8px;
  box-sizing: border-box;
  border-radius: 6px;
}

.toubut4 {
  border: solid 1px #cccccc;
  color: white;
  background-color: #cccccc;
  padding: 5px 8px;
  box-sizing: border-box;
  border-radius: 6px;
}

.lookmore img {
  margin: auto;
  margin-top: 20px;
  margin-bottom: 60px;
  cursor: pointer;
  transition: transform 0.3s ease-in-out;
}

.lookmore img:hover {
  transform: rotate(360deg);
}

//赛事介绍

/*
响应1500px
 */
@media screen and (max-width: 1500px) {
  :deep(.el-carousel__indicators--right) {
    left: 20px;
    top: 80%;
  }

  :deep(..el-carousel__indicators--vertical) {
    left: 20px;
    top: 10%;
    transform: translateY(-80%);
  }

  :deep(.el-carousel__button) {
    width: 14px;
    height: 50px;
  }

  .swiperbox {
    position: relative;
  }

  :deep(.el-carousel__container) {
    height: 800px;
  }

  .tou {
    width: 80%;
  }
}

/*
响应1200px
 */
@media screen and (max-width: 1200px) {
  :deep(.el-carousel__indicators--right) {
    left: 20px;
    top: 80%;
  }

  :deep(..el-carousel__indicators--vertical) {
    left: 20px;
    top: 10%;
    transform: translateY(-80%);
  }

  :deep(.el-carousel__button) {
    width: 14px;
    height: 50px;
  }

  .swiperbox {
    position: relative;
  }

  :deep(.el-carousel__container) {
    height: 800px;
  }

  .tou {
    width: 90%;
  }
}

/*
响应768px
 */
@media screen and (max-width: 768px) {
  :deep(.el-carousel__indicators--right) {
    left: 20px;
    top: 80%;
    display: none;
  }

  :deep(..el-carousel__indicators--vertical) {
    left: 20px;
    top: 10%;
    transform: translateY(-80%);
  }

  :deep(.el-carousel__button) {
    width: 14px;
    height: 50px;
  }

  .swiperbox {
    position: relative;
  }

  :deep(.el-carousel__container) {
    height: 200px;
  }

  .tit-eng {
    font-size: 24px;
  }

  .tit-p {
    font-size: 24px;
  }

  .touitem {
    height: 300px;
    padding: 0;
  }

  .toumask {
    width: 80%;
    height: 90%;
    left: 58%;
    padding: 0 10px;
  }

  .touleft {
    width: 70%;

    & img {
      border-radius: 4px;
    }
  }

  .touright {
    display: none;
  }

  .touitem:nth-child(2) {
    flex-direction: row;

    & .toumask {
      width: 80%;
      height: 90%;
      left: 98%;
      padding: 0 10px;
    }

    .touleft {
      width: 70%;

      & img {
        border-radius: 4px;
      }
    }
  }

  .toutit {
    margin-bottom: 0;
    font-size: 14px;
  }

  .toutype {
    margin-top: 0;
    font-size: 10px;
  }

  .timeson {
    margin-top: 0;
  }

  .toubuts {
    margin-top: 0;
  }

  .lookmore img {
    margin-top: 10px;
    margin-bottom: 20px;
  }
}
</style>
